API_KEY subjects authenticate technical clients via the
Hostsharing-Api-Key HTTP header instead of a Keycloak OIDC
JWT, e.g. automation programs, completely bypassing Keycloak. Only a
global-admin may create API_KEY subjects. The clear-text API-key is
returned only once, in the response of creating the API_KEY subject;
just its hash gets stored. Like GROUP subjects, API_KEY subjects cannot
have an account. Global API_KEY subjects do not belong to a realm, thus
their name must neither contain a - (the realm-prefix
delimiter) nor a / (the GROUP subject marker).
| name | value |
|---|---|
| subjectUuid | a91c0001-0000-0000-0000-000000000001 |
| subjectName | master.key |
The response contains the generated clear-text API-key (property
apiKey) exactly once; it cannot be retrieved again.
HTTP POST "/api/rbac/subjects" \
-H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
`# {` \
`# "sub" : "uuid<hsh-alex_superuser>"` \
`# }` \
<<EOF
{
"uuid" : "a91c0001-0000-0000-0000-000000000001",
"name" : "master.key",
"type" : "API_KEY"
}
EOF
=> status: 201 CREATED a91c0001-0000-0000-0000-000000000001
{
"uuid" : "a91c0001-0000-0000-0000-000000000001",
"name" : "master.key",
"organization" : "master",
"type" : "API_KEY",
"apiKey" : "hsak_master.key.10ed15d1b930bfc6b6a9b3d6fc0b669d9ebf99156cda8ad11e762d9a098f4e41",
"scopes" : null,
"expiresAt" : null
}
The grant API needs the UUID of the role which we want to grant.
HTTP GET "/api/rbac/roles?name=rbac.global%23global%3AADMIN" \
-H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
`# {` \
`# "sub" : "uuid<hsh-alex_superuser>"` \
`# }`
=> status: 200 OK
[ {
"uuid" : "2366934b-3ba5-453a-a070-78698db295e0",
"object.uuid" : "a8842cb7-7284-468a-9e78-07e6fea8bc98",
"objectTable" : "rbac.global",
"objectIdName" : "global",
"roleType" : "ADMIN",
"roleName" : "rbac.global#a8842cb7-7284-468a-9e78-07e6fea8bc98:ADMIN",
"roleIdName" : "rbac.global#global:ADMIN"
} ]
HTTP POST "/api/rbac/grants" \
-H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
`# {` \
`# "sub" : "uuid<hsh-alex_superuser>"` \
`# }` \
-H 'Hostsharing-Assumed-Roles: rbac.global#global:ADMIN' \
<<EOF
{
"assumed" : true,
"grantedRole.uuid" : "2366934b-3ba5-453a-a070-78698db295e0", // globalAdminRoleUuidToGrant
"granteeSubject.uuid" : "a91c0001-0000-0000-0000-000000000001"
}
EOF
=> status: 201 CREATED 2366934b-3ba5-453a-a070-78698db295e0 // globalAdminRoleUuidToGrant
HTTP GET "/api/hs/accounts/current" \
-H "Hostsharing-Api-Key: $HSADMINNG_API_KEY"
=> status: 200 OK
{
"subject" : {
"uuid" : "a91c0001-0000-0000-0000-000000000001",
"name" : "master.key",
"organization" : "master",
"type" : "API_KEY"
},
"person" : null,
"globalAdmin" : true
}
generated on 2026-08-10 04:34:34 for branch HEAD